<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:th="http://www.thymeleaf.org"
	xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:include="common/template :: res(title='项目追加登记')">

</head>
<body style="padding-left:5px;">
<script type="text/javascript">
		$(function(){
			
			$('input:radio[name="userType"]').change(function() {
				userTypeAction();
			});
			$('#formSubimt').click(function(){
				var userType = $('input:radio[name="userType"]:checked').val();
				doRequest({
					type:'POST',
					url:'assureProject',
					data:{
						projectNo:$('#projects').val(),
						assureAmt:$('#assureAmt').val(),
						assureIncome:$('#assureIncome').val(),
						assureType:userType,
						assureIpsAcctNo:$('#ipsAcctNo').val()
					}
				},function(data){
					console.log(data);
					print('项目追加登记成功');
					location.href="redirect?redirect=list/project";
				});
			});
			
			
			
			
			projectAction();
			userTypeAction();
			$('#projects').change(function() {
				var _selected=$(this).find("option:selected");
				var amount=_selected.data('amount');
				$('#assureAmt').val(amount);
			});
			
			
		});
		
		function userTypeAction(){
			var $selectedvalue = $("input[name='userType']:checked").val();

			doRequest({
				url:'users',
				data:{
					type:$selectedvalue
				}
			},function(data){
				console.log(data);
				var html ='';
				
				$(data).each(function(index,d){
					
					var showInfo=$selectedvalue==1?d.realName:d.enterName;
					html +='<option value="'+d.ipsAcctNo+'"  >'+showInfo+'</option>';
				});
				
				$('#ipsAcctNo').html(html);
			});

		}
		
		function projectAction(){
			

			doRequest({
				url:'q/project'
			},function(data){
				console.log(data);
				var html ='<option> -- 选择 -- </option>';
				
				$(data).each(function(index,d){
					html +=('<option value="'+d.projectNo+'"  data-amount="'+d.projectAmt+'">'+d.projectName+'</option>');
				});
				$('#projects').html(html);
			});
		}
	</script>
	<div class="alert alert-success toptips" role="alert" id="js_tooltips"  style="display:none;z-index:100;">信息展示窗口</div>
	<div class="page-header">
	<h2>江苏亦融在线  <small>支付调试</small></h2>

	</div>
<ol class="breadcrumb">
  <li ><a href="index">首页</a> </li>
  <li class="active">项目追加登记</li>
</ol>
	<div class="form-horizontal" style="padding-left:20px;" >
		<div class="form-group">
			<label>用户类型</label>
			<div>
				<label class="checkbox-inline"> <input type="radio"
					name="userType" value="1" checked="checked" />个人
				</label> <label class="checkbox-inline"> <input type="radio"
					name="userType" value="2" />企业
				</label>
			</div>
		</div>
		<div class="form-group">
			<label >担保用户 </label> 
			<select class="combobox" id="ipsAcctNo"   style="width:200px;"> </select>
			
		</div>
		
		<div class="form-group">
			<label >项目名称</label> 
			<select class="combobox" id="projects"  style="width:200px;"> </select>
		</div>
		<div class="form-group">
			<label >担保金额</label> <input type="text" class="form-control"
				id="assureAmt" value="100"/>
		</div>
		<div class="form-group">
			<label >担保收益</label> <input type="text" class="form-control"
				id="assureIncome" value="0"/>
		</div>
		
		
		<div class="form-group">
			
				<button  class="btn btn-default" id="formSubimt">提交</button>
			
		</div>
	</div>
<div style="display: none;">
		<form action="http://180.168.26.114:20010/p2p-deposit/gateway.htm" method="post" id="submitForm"  target="_blank">
		
			<input type="text" name="operationType" id="operationType" value="trade.freeze"/>
			<input type="text" name="merchantID" id="merchantID"/>
			<input type="text" name="sign" id="sign"/>
			<input type="text" name="request" id="request"/>
		</form>
	</div>
	
</body>
</html>